const { merge } = require("webpack-merge");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const commom = require("./webpack.common");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCssAssetsWebpackPlugin = require("optimize-css-assets-webpack-plugin");
const TerserWebpackPlugin = require("terser-webpack-plugin");
const path=require('path')
module.exports = merge(commom, {
    mode: "production",
    devtool: false,
    optimization: {
        usedExports: true,
        concatenateModules: true,
        minimize: true,
        sideEffects: true,
        // splitChunks: {
        //   chunks: "all",
        // },
        minimizer: [
            new OptimizeCssAssetsWebpackPlugin(),
            new TerserWebpackPlugin(),
        ],
    },
    plugins: [
        new CleanWebpackPlugin(),
        new CopyWebpackPlugin({
            patterns: [
                {
                    from: path.join(__dirname, 'public'),
                    to: 'assets'
                }
            ],
        }),
        new MiniCssExtractPlugin({
            filename: '[name]-[contenthash:8].bundle.css'
        }),
    ],
});
